package com.admin.service;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.admin.dao.AdminProfileDao;
import com.common.model.AdminUser;

@Service
public class AdminProfileService {
	@Autowired
	@Qualifier("adminProfileDao")
	AdminProfileDao dao;
	/**
	 * 更新个人资料(电话,姓名,性别)
	 * @param user 
	 */
	public void updateInfo(AdminUser user,HttpSession session){
		AdminUser admin=(AdminUser)session.getAttribute("user");
		admin.setName(user.getName().trim());
		admin.setTelephone(user.getTelephone().trim());
		admin.setGender(user.getGender().trim());
		dao.updateInfo(user);
	}
	/**
	 * 修改密码
	 * @param id 管理员id
	 * @param newPass 新密码
	 * @return
	 */
	public void updatePass( int id,String newPass,HttpSession session){
		AdminUser admin=(AdminUser)session.getAttribute("user");
		admin.setPassword(newPass);
		dao.updatePass(id, newPass);
	}
}
